<?php

namespace App\Listeners;

use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Overtrue\LaravelUEditor\Events\Uploaded;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Session;

class TmpSaveUploadPic
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  object  $event
     * @return void
     */
    public function handle(Uploaded $event)
    {
        //将上传的图片路径临时存放在Session
        // session(['uploadPic' => $event->result['url'] ]);
        // Session::put('uploadPic', $event->result['url']);
        // Session::put('uploadPic', 666);
        // Session::save();
        // Redis::set('test2', json_encode($event->result));
        // Redis::set('test', $event->result['url']);
        Redis::sAdd('uploadpic:sessionID:' . Session::getId(), $event->result['url']);

        // $request->session()->put('uploadPic2', $event->file);


    }
}
